package com.googlecode.intellimars.sabotter.action;

import com.googlecode.intellimars.sabotter.SabotterPlugin;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataKeys;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import twitter4j.TwitterException;

public class RefreshViewAction extends AnAction {
    private static final Logger LOG = Logger.getInstance("sabotter");

    public RefreshViewAction() {
        getTemplatePresentation().setIcon(IconLoader.getIcon("/actions/sync.png"));
    }
    public void actionPerformed(AnActionEvent e) {
        Project project = DataKeys.PROJECT.getData(e.getDataContext());
        if (project != null) {
            SabotterPlugin plugin = project.getComponent(SabotterPlugin.class);
            try {
                plugin.updateTimeLine();
            }
            catch (TwitterException ex) {
                LOG.error(ex);
            }
        }
    }
}
